#include "Camera.hpp"

/** 
* Create new camera with specified size and target.
*/
Camera::Camera(Entity* cameraTarget, int cameraWidth, int cameraHeight) {
    target = cameraTarget;
    width = cameraWidth;
    height = cameraHeight;
    scale = 1;
}

void Camera::setTarget(Entity* set) {
    target = set;
}

float Camera::getScale() {
    return scale;
}

void Camera::setScale(float val) {
    scale = val;
}

int Camera::getX() {
    if (target != 0)
        return target->x;
}

int Camera::getY() {
    if (target != 0)
        return target->y;
}

int Camera::getTileX(){
    return target->x/32;
}

int Camera::getTileY(){
    return target->y/32;
}

int Camera::getTopTile(){
    int midTile = getTileY();
    return midTile - (getHeight()/32 + 2)/2;
}

int Camera::getLeftTile(){
    int midTile = getTileX();
    return midTile - (getWidth()/32 + 1)/2;
}

int Camera::getWidth() {
    return width;
}

int Camera::getHeight() {
    return height;
}

void Camera::setWidth(int value) {
    width = value;
}

void Camera::setHeight(int value) {
    height = value;
}

Camera::~Camera() {
    target = 0;
}